package DNA序列;

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] s = in.next().toCharArray();
        int x = in.nextInt();
        int maxcnt = 0, cnt = 0, n = s.length, begin = 0;
        for (int i = 0; i < x; i++) {
            if (s[i] == 'C' || s[i] == 'G') {
                cnt++;
            }
        }
        maxcnt = cnt;
        for (int l = 0, r = x - 1; r < n - 1; r++, l++) {
            if (s[l] == 'C' || s[l ] == 'G') {
                cnt--;
            }
            if (s[r + 1] == 'C' || s[r + 1] == 'G') {
                cnt++;
            }
            if (maxcnt < cnt) {
                maxcnt = cnt;
                begin = l + 1;
            }
        }
        for (int i = begin; i < x + begin; i++) {
            System.out.print(s[i]);
        }
    }
}
